<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>管理系统</title>

    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
 

    <link href="../vendors/datatables.net-scroller-bs/css/scroller.bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet"   href="css/jquery.datetimepicker.min.css">
    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
    <link rel="stylesheet"   href="css/pubuse.css">
    
  </head>

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
            <div class="navbar nav_title" style="border: 0;">
              <a href="index.html" class="site_title"><i class="fa fa-paw"></i> <span>出票管理系统</span></a>
            </div>

            <div class="clearfix"></div>

            <!-- menu profile quick info -->
            <div class="profile clearfix">
              <div class="profile_pic">
                <img src="img/b4.png" alt="..." class="img-circle profile_img">
              </div>
              <div class="profile_info">
                <span>Welcome</span>

              </div>
            </div>
            <!-- /menu profile quick info -->

            <br />

            <!-- sidebar menu -->
            <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
              <div class="menu_section">
                <!--#include virtual="/webadmin/store/share/publeftbar.html"-->
                 
              </div>
            

            </div>
           

          </div>
        </div>

        <!-- top navigation -->
        <div class="top_nav">
          <div class="nav_menu">
            <nav>
              <ul class="nav navbar-nav navbar-right">
                <li class="">
                  <button type="button" class="" id="logoutbtn"   onclick="loginOut()">
                    退出 
                   </button>
               
                </li>

              </ul>
            </nav>
          </div>
        </div>
        <!-- /top navigation -->

        <!-- page content -->
        <div class="right_col  ticket_right_rol" role="main">
          <div class="">
           

            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>出票详情</h2>
                    <div class="clearfix"></div>
                  </div>
                  <div class="table-responsive">
                      <table class="table table-striped jambo_table bulk_action">
                          <colgroup>
                            <col  width="15%">
                            <col  width="35%">
                            <col  width="15%">
                            <col  width="35%">
                           
                        </colgroup>
                       
                          <tbody   id=""  class="ticketinfo-tbody">
                              <tr class="even">
                                  <td>出票状态</td><td id="ticket_state"></td>
                                  <td>彩种编号</td><td id="gameid"></td>
                             </tr>
                             <tr class="even">
                                <td>期次编号</td><td id="ticket_poreid"></td>
                                <td>机器编号</td><td id="machineid"></td>
                           </tr>
                             <tr class="even">
                                <td>票号</td><td id="ticketid"></td>
                                <td>订单编号</td><td id="orderid"></td>
                             </tr>
                             <tr class="even">
                                <td>投注时间</td><td id="createtime"></td>
                               <td>截止时间</td><td id="endtime"></td>
                             </tr>
                             <tr class="even">
                                <td>分配时间</td><td id="fenpeitime"></td>
                                <td>接单时间</td><td id="taketime"></td>
                            </tr>
                            <tr class="even">
                                <td>出票时间</td><td id="outtime"></td>
                                <td>兑奖时间</td><td id="drawtime"></td>
                             </tr>
                             <tr class="even">
                                <td>单倍金额</td><td id="money"></td>
                                <td>投注倍数</td><td id="mulity"></td>
                             </tr>
                             <tr class="even">
                                <td>投注金额</td><td id="tmoney" colspan="3"></td>
                              </tr>
                              <tr class="even">
                                  <td>投注内容</td><td id="codes" colspan="3"></td>
                              </tr>
                              <tr class="even">
                                  <td>出票赔率</td><td id="cpodds" colspan="3"></td>
                              </tr><tr class="even">
                                  <td>兑奖金额</td><td id="wmoney"></td>
                                  <td>计奖金额</td><td id="sysmoney"></td>
                              </tr>
                              <tr class="even" >
                                  <td  >撤单原因</td><td  id="cancel_season"  colspan="3"></td>
                              </tr>
                              <tr class="even" >
                                  <td  >票据图片</td><td  id="ticketImgtd"  colspan="3"></td>
                              </tr>
 
                          </tbody>
                        </table>
                        <form id="uploadForm" method="post" enctype="multipart/form-data"  class="uploadwrap">
                              <input type="hidden" id="selticket" name="ticketid"  value="">

                           <div class="addpro-img">
                              <span class="addimg-text">重新上传票样:</span>
                              <div class="addimg-btn">
                                    <input type="file" id="uplosdprofile" name="img">
                                    <label for="uplosdprofile"></label>
                              </div>
                             
                           </div>
                           <div class="showimg-box" id="showimgbox">
                                
                            </div>
                            <div  class="uploadbtnwrap">
                                <a  href="javascript:;"  id="uploadbtn"  class="btn  btn-info"  data-placement="right"   data-content="上传成功">上传</a>
                             </div>
                            <input type="hidden" id="remarkuplod"  value="">
                          
                        </form>

                       

                  </div>





                 
                </div>
              </div>

            </div>
          </div>
        </div>

              
       
     
      </div>
    </div>

   
   


     <!-- 公用 弹窗 -->

     <div class="modal fade" id="loginoutModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 class="modal-title" id="myModalLabel"></h4>
            </div>
            <div class="modal-body">
              <div  id="tipsContent"></div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
            </div>
          </div>
        </div>
      </div>

  





    <!-- jQuery -->
    <script src="../vendors/jquery/dist/jquery.min.js"></script>
    <script  src="js/publicuse.js"></script>
    <!-- Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>

    <script src="js/jquery.datetimepicker.full.min.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
  <script>
    (function(){
      
       getAllTicketInfo();
       previewProImg();
       doUpload();
   function getAllTicketInfo(){
         var tid = location.search.getParam("tid");
         var type = location.search.getParam("type");
          $.ajax({
              type:"get",
              url:"/sys?fid=103&type="+type+"&ticketid="+tid,
              dataType:"json",
              success:function( info ){
                  var code = info.code;
                  var desc = info.desc;
                  if( code == 1 )
                  {
                      var data = info.data;
                      var stateArr = ["已撤单","未分配","已分配","已接单","已出票","已计奖","已兑奖"];
                      var state = data.state;
                      var cancelSeason = "", cpodds="";
                      var showTicketImg = '';
                      
                      if( state < 3 &&  state != -1 )//state < 3表示撤单原因
                      {
                         cancelSeason = data.odds;
                     
                      }
                      else
                      {
                          cpodds = data.odds;
                          showTicketImg = '<img  src="/sys?fid=104&type='+type+'&ticketid='+tid+'"   id="ticketimg">';
                      }

                      $("#ticketid").html( data.ticketid );
                      $("#orderid").html( data.orderid );
                      $("#machineid").html( data.siteid );
                      $("#ticket_poreid").html( data.period ? data.period :"");
                      $("#createtime").html( data.createtime );
                      $("#endtime").html( data.endtime );
                      $("#siteid").html( data.siteid );
                      $("#ticket_state").html( stateArr[data.state + 1]);
                      $("#mulity").html( data.mulity );
                      $("#tmoney").html( data.tmoney );
                      $("#wmoney").html( data.wmoney );
                      $("#sysmoney").html( data.sysmoney );
                      $("#codes").html( data.codes );
                      $("#gameid").html( data.gameid );
                      $("#outtime").html( data.outtime );
                      $("#drawtime").html( data.drawtime );
                      $("#taketime").html( data.taketime );
                      $("#money").html( data.money );
                      $("#cpodds").html( cpodds );
                      $("#fenpeitime").html( data.fenpeitime );
                      $("#cancel_season").html( cancelSeason);
                      $("#ticketImgtd").html(showTicketImg);

                      $("#ticketimg").click(function(){
                          $(this).toggleClass("autowidth");
                      });
                    


                  }
                  else
                  {
                      if( code == 2 )
                      {
                        location.href = "login.html";
                      }
                      else
                      {
                            $("#tipsContent").html( desc );
                            $("#loginoutModal").modal();

                      }
                  }

              }
          });

       }


   function previewProImg(){
         var _timer;
        $("#uplosdprofile").unbind("click").click(function(){
          
             this.value = "";
             var that = this;
             clearTimeout(_timer);
             _timer = null;
             _timer = setInterval(function() {
                if (that.files[0] && that.files[0].size) {
                  
                  
                    previewImg(that);
                    clearTimeout(_timer);
                    _timer = null;
                }
            }, 10);


        });

   }
   function  previewImg( that){
        var _this = this;
        var reader = new FileReader();
        var file = that.files[0];
        var fileName = file.name;
        var imageType = /^image\//;
        if( !imageType.test(file.type) )
        {
            alert("请选择图片上传!");
            return false;
        }
        var imgSize = file.size;
        // if( imgSize > 1024*1024*3 )
        // {
        //     alert("请选择小于3MB的图片上传!");
        //     return false;
        // }
        reader.onload = function(){
          
            $("#showimgbox").html('<div class="imgbox"><img  src="'+this.result+'"></div>');
            $("#remarkuplod").val(1);

        }
        reader.readAsDataURL(file);

     } 
   
   function doUpload(){
       var tid = location.search.getParam("tid");
       $("#selticket").val(tid);
       $("#uploadbtn").unbind("click").click(function(){

             var isUpload =  $("#remarkuplod").val();
          
             if( !isUpload)
             {
                alert("请选择上传图片")
                return false;
                
             }
            
             var formDate = new FormData($("#uploadForm")[0]);
             $.ajax({
                type:"post",
                url:"/sys?fid=106",
                dateType:"json",
                processData: false,
                contentType: false,
                data: formDate,
                success:function( info ){
                    var code = info.code;
                    var desc = info.desc;
                    if( code == 1 )
                    {
                        getAllTicketInfo();
                        $("#uploadbtn").popover("show");
                        setTimeout(function(){
                            $("#uploadbtn").popover("destroy");
                            $("#uploadForm  input").val("");
                            $("#showimgbox").html("");

                        }, 300);

                    }
                    else
                    {
                          $("#editorMachineModal").modal("hide");
                            if( code == 2 )
                            {
                            
                                $("#myModalLabel").html("你还未登录");
                                $("#loginoutModal").modal();
                                setTimeout(function(){
                                    location.href = "login.html";
                                }, 800);
                            }
                            else
                            {
                                $("#myModalLabel").html(desc);
                                $("#loginoutModal").modal();

                            }
                     
                    }


                },
                error:function( xhlrequst, textStatus){
                   console.log(xhlrequst.status);
                   $("#myModalLabel").html(textStatus);
                    $("#loginoutModal").modal();

                }

            });


         });


   }

       


    }());
  </script>
  </body>
</html>